using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Carmove : MonoBehaviour, ICarmove
{
    bool isleftmove = false;
    bool isrightmove = false;
   
   
    public void Carmovleft()
    {
         isleftmove = true;
    }

    public void Carmovright()
    {
        isrightmove = true;
    }

    internal void Init(int v)
    {
      if(v==0)
        {
            Carmovleft();
        }
        else
        {
            Carmovright();
        }
        transform.position = new Vector3(transform.position.x, 0, transform.position.z);
    }

    // Start is called before the first frame update
    void Start()
    {
        Destroy(gameObject,3f);
    }
   
    // Update is called once per frame
    void Update()
    {
        if(isleftmove)
        {
            transform.Translate(Vector3.back * 10 * Time.deltaTime);

        }
        if(isrightmove)
        {
            transform.Translate(Vector3.forward * 10 * Time.deltaTime);
        }
    }
}
